<?php

	require_once('../scripts/query/vocabulary.php');
	
	function link_query_to_graph($filename,$fight) {
		// Opening the file and reading it
		$qvalues = file($filename); 
		
		if ($fight == "color") {
			$array_terms = vocabulary::$colors;
		}
		else if ($fight == "emotion") {
			$array_terms = vocabulary::$emotions;		
		}
		
		$index_dim = 0;
		$length = 0;
		
		
		// Building the array that will contain the figures
		foreach($array_terms as $dim) {
				$t_values = preg_split('/ /',$qvalues[$index_dim]);
				$leftS[$dim] = $t_values[0] ;
				$rightS[$dim] = $t_values[1] ;
				if(max($t_values[0],0) + max($t_values[1],0) - $length > 0) {
					$length = max($t_values[0],0) + max($t_values[1],0);
				}

				$index_dim++;
			}

		$length = ceil($length * 100 + 1) / 100.0;
		foreach($array_terms as $dim) {
			$left_val = $leftS[$dim]>0? $leftS[$dim] : 0;
			$right_val = $rightS[$dim]>0? $rightS[$dim] : 0;
			echo 'display_one_dim_result(\'' . $dim . '\',' . $left_val  . ',' . $right_val .',' . $length. ');';
			$index_dim ++;
		}
		
	}
	
?>